import request from '@/utils/request';

//条件分页查询用户记录
export async function getUserList(msg: object) {
  return request('/bf/uc/user/page', {
    method: 'post',
    data: msg,
  });
}

//获取用户信息

export async function getUserInfo() {
  return request('/bf/uc/user_center/get_user_info', {
    method: 'get',
  });
}

//机构树
export async function getOrgTree(params: object) {
  return request('/bf/common/org/get_org_tree', {
    method: 'get',
    params,
  });
}

//条件分页查询角色列表
export async function getRoleList(msg: object) {
  return request('/bf/uc/role/page', {
    method: 'post',
    data: msg,
  });
}

//根据指定范围加载菜单资源树
/**
 * {
 * contain: 2,
 * idList: [xxx],
 * idType: 2,
 * scope: 2,
 */
//scope传2，contain传2。如果是新增，idType传2，idList传角色的归属机构id；
//如果是编辑和详情的话，idType传3，idList传角色的id
export async function getMenuByScope(msg: object) {
  return request('/bf/common/menu/get_by_scope', {
    method: 'post',
    data: msg,
  });
}

//新建角色
export async function saveRole(msg: object) {
  return request('/bf/uc/role/save', {
    method: 'post',
    data: msg,
  });
}

//修改角色
export async function updateRole(msg: object) {
  return request('/bf/uc/role/update', {
    method: 'post',
    data: msg,
  });
}
//通过ID查询角色详细信息
export async function roleDetailsById(id: string | number) {
  return request(`/bf/uc/role/get/${id}`, {
    method: 'get',
  });
}

//通过ID删除角色
export async function deleteRoleById(id: string | number) {
  return request(`/bf/uc/role/delete/${id}`, {
    method: 'post',
  });
}

//批量修改角色状态 1-启用或 0-停用
export async function updateRoleStatus(msg: object) {
  return request('/bf/uc/role/status', {
    method: 'post',
    data: msg,
  });
}

// /​bf​/uc​/role​/get_by_user
// 特殊数据授权标签
export async function getUserRoleList(msg: object) {
  return request('/bf/uc/role/get_by_user', {
    method: 'post',
    data: msg,
  });
}
// 特殊数据授权标签
export async function getSpecialLabelList(msg: object) {
  return request('/bf/sys/label/list', {
    method: 'post',
    data: msg,
  });
}
//新建用户记录
export async function saveUser(msg: object) {
  return request('/bf/uc/user/save', {
    method: 'post',
    data: msg,
  });
}

//修改用户记录
export async function updateUser(msg: object) {
  return request('/bf/uc/user/update', {
    method: 'post',
    data: msg,
  });
}

//加载管理员管理范围的人员，返回UserEmployeeVO结构的数据集
export async function getByMgtorg(msg: object) {
  return request('/bf/uc/employee/get_by_mgtorg', {
    method: 'post',
    data: msg,
  });
}

//用户详情显示接口
export function userDetailsById(id: string | number) {
  return request(`/bf/uc/user/get/${id}`, {
    method: 'get',
  });
}

//批量修改用户状态 0：停用，1：启用，解锁
export async function updateUserStatus(msg: object) {
  return request('/bf/uc/user/change_status', {
    method: 'post',
    data: msg,
  });
}

//通过ID删除用户
export async function deleteUserById(id: string | number) {
  return request(`/bf/uc/user/delete/${id}`, {
    method: 'post',
  });
}

//用户修改密码
export async function updateUserPassword(msg: object) {
  return request(`/bf/uc/user/modify_pwd`, {
    method: 'post',
    data: msg,
  });
}

// 批量授权
export async function batchAuth(msg: object) {
  return request(`/bf/uc/user/batch_auth`, {
    method: 'post',
    data: msg,
  });
}

//为角色分配授权用户
export async function roleAuthorize(msg: object) {
  return request(`/bf/uc/role/authorize`, {
    method: 'post',
    data: msg,
  });
}

//根据角色ID获取用户授权信息

export async function getAuthorizedUserByRoleId(roleId: string | number) {
  return request(`/bf/uc/role/authorized_user/${roleId}`, {
    method: 'get',
  });
}

//根据用户id重置密码 返回一个新的密码
export async function resetPassword(userId:string | number) {
  return request(`/bf/uc/user/reset_pwd/${userId}`, {
    method: 'post',
  });
}
